/**
 * 
 */
package com.taobao.wolfwolf.hibernate.dao.impl;

import java.util.List;

import com.taobao.wolfwolf.hibernate.dao.CustomerDao;
import com.taobao.wolfwolf.hibernate.pojo.Customer;

/**
 * @author Tux
 *
 * 创建时间: 2011-5-4 下午06:35:04
 */
@SuppressWarnings("unchecked")
public class CustomerDaoImpl extends BaseDaoImpl implements CustomerDao {
	
	public Customer findById(int id) throws Exception {
		return (Customer) getHibernateTemplate().get(Customer.class, id);
	}
	
	public List<Customer> findByName(String name) throws Exception {
		return super.findByProperty(Customer.class, "name", name);
	}

	public List<Customer> findAll() throws Exception {
		return getHibernateTemplate().find("from Customer");
	}

	public long getTotal() throws Exception {
		return super.countByCriteria(Customer.class);
	}

	public List<Customer> paging(int page, int limit) throws Exception {
		return super.findByCriteriaByPage(Customer.class, page, limit);
	}

	public List<Customer> findByPinyin(String abbr) throws Exception {
		return super.findByProperty(Customer.class, "pinyin", abbr, 3);
	}
}
